package work;

public class Schedule {

    //总数
    private int all;

    public Schedule(int all) {
        this.all = all;
    }

    private String line = "当前已经完成:0.0%";

    public void start() {
        System.out.print(line);
    }

    private void rate(int n) {

        for (int i = 0; i < 100; i++) {

            for (int j = 0; j < line.length(); j++) {
                System.out.print("\b");
            }
            line = "当前已经完成:" + i + "%";
            System.out.print(line);
        /*    try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }*/
        }

       /* double r = 1.0 * n / all;
        if (r > 1) {
            r = 1;
        }
        for (int i = 0; i < end.length(); i++) {
            System.out.print("\b");
        }
        end = r * 100 + "%";
        System.out.print(end);*/
    }

    public void end() {
        System.out.println();
    }

    public static void main(String[] args) throws InterruptedException {

        String rate = "0.00%";

        System.out.print("完成:" + rate);

        for (int i = 0; i < 100; i++) {
           // Thread.sleep(100);
            String back = "";
            for (int j = 0; j < rate.length(); j++) {
                back += '\b';
            }
            rate = i + "%";
            System.out.print(back + rate);
        }

    }

}
